MYOWD=/data/data/com.termux/files/home/gitee/emp
Config_Dir=$MYOWD
Config_File="$Config_Dir/config.md"
List_Dir="$Config_Dir/lists"
Player_Cmd='ffplay -autoexit -loglevel error -showmode 0'
Player_Cmd='mpv --quiet'
if [[ -d /tmp ]];then
	Tmp_File='/tmp/.file'
else
	Tmp_File='/data/data/com.termux/files/home/.cache/emp/.file'
fi
#cat config.md
Get(){
	case $# in
		1)
		awk "/^- $1/{print \$3}" $Config_File ;;
		2|3)
		case $1 in
			pipe)
				awk "/^- $2:/{print \$3}" $3 ;;
			info)
				sed -E "s/.*$2:([^,]*).*/\1/" $3 ;;
		esac ;;
	esac
}
Set(){
	case $1 in
		info)
			sed -E "s#(.*$2:)([^,]*)(.*)#\1$2\3#" $3 ;;
		*)
			sed -E "/^- $1/{;s#(^[^:]*:).*#\1 $2#g;}" -i.k $Config_File ;;
	esac
}
lcat(){
	awk -vRS='' "/name: $Playlist/{print \$0}" $Config_File
}
lget(){
	case $1 in
		filename|url|info) lcat|sed -nE "/^- $1:/{s#^- $1: ##;p}" ;;
		*) lcat|Get pipe $1 ;;
	esac
}
lset(){
	sed -E "/^- name: $Playlist/,/^$/{ \
		/^- $1:/{;s#(^- [^:]*:).*#\1 ${2//&/SEDFS}#;s#SEDFS#\&#g;}  
	}"  -i.k $Config_File
#		/^- $1:/{;s#(^- [^:]*:).*#\1 $2#;;}  如果包含&会出大问题
}
#Playlist=$(Get 'Playlist')
#lset url 'http://vodkgeyttp8.vod.126.net/cloudmusic/JDAiYCAkOSA3YiAyJCQgIA==/mv/221004/2c4b7910afe1848d5e25973dce0225d3.mp4?wsSecret=8221527a543641fbdba555e35fd2413fwsTime=1664267657wsTime=1664267657wsTime=1664267657wsTime=1664267657wsTime=1664267657wsTime=1664267657'
H(){
	echo '''
Get 'Playlist'
Get info filename i #size,id,net,
lcat |Get pipe num  #mode,file,filename,totalnum,dir,name
lget file
lset num 4
Set info size 5m
Set Playlist q

Config_File='/home/h/data/gitee/emp/config.md'
Player_Cmd='ffplay -autoexit -loglevel error -showmode 0'
Playlist=
dir=
totalnum=

'''
}

Playlist=$(Get 'Playlist')


